package com.runtu.domain.activity.service.discount.impl;

import com.runtu.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import com.runtu.domain.activity.service.discount.AbstractDiscountCalculateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @ClassName NCalculateService
 * @Description N元购买优惠
 * @date 2025/7/19 20:42
 * @Version 1.0
 */

@Slf4j
@Service("N")
public class NCalculateService extends AbstractDiscountCalculateService {


    @Override
    protected BigDecimal doCalculate(BigDecimal originalPrice, GroupBuyActivityDiscountVO.GroupBuyDiscount groupBuyDiscount) {


        //获取N元购的N
        String marketExpr = groupBuyDiscount.getMarketExpr();
        BigDecimal x = new BigDecimal(marketExpr);
        if(originalPrice.compareTo(x) <= 0){
            return originalPrice;
        }

        return x;
    }
}
